window.onload = function () {
    new Vue({
        el: "#hh",
        data() {
            return {
                tableData: [],
                drawer: false,
                User: "",
                APssWord: "",
                Super: "",
                Choose_Value: "",
                Option: [{lable: "超级用户", value: 1}, {lable: "普通用户", value: 0}],
                ChooseRow:{
                    Id:"",
                    Thename:"",
                    APassWord:"",
                    Options: [{lable: "超级用户", value: 1}, {lable: "普通用户", value: 0}],
                    Super:null
                },
                Enter:false,
            }
        },
        methods: {
            GetAll() {
                axios.get("http://localhost:8080/Users").then(res => {
                    console.log(res.data.data);
                    this.tableData = res.data.data;
                });
            },
            InserUser() {
                var json = {
                    Thename: this.User,
                    APassWord: this.APssWord,
                    Super: "",
                    Choose:""
                }
                var jsonstring = JSON.stringify(json);
                axios.post("http://localhost:8080/Users", json).then(e => {
                    if (e.data.code == 20011) {
                        this.$message({
                            message: "添加成功",
                            type: "success"
                        });
                        this.drawer=false;
                    } else {
                        this.$message({
                            message: "添加失败",
                            type: "warning"
                        });
                        this.drawer=false;
                    }
                });

            },
            UpData(){

                var json={
                    Id:this.ChooseRow.Id,
                    Thename:this.ChooseRow.Thename,
                    APassWord:this.ChooseRow.APassWord,
                    Super:this.ChooseRow.Choose
                }
                console.log(json)
                axios.put("http://localhost:8080/Users",json).then(res=>{
                    if (res.data.code==20031){

                        this.$message({
                            message:"更改成功",
                            type:"success"
                        });
                        this.Enter=false;
                    }else{
                        this.$message({
                            message:"更改失败",
                            type:"warning"
                        });
                    }
                });

            },
            UpRow(le){
                this.Enter=true;
                this.ChooseRow=le;
            }
        }
    })
}